package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController(value = "adminShopController")
@RequestMapping("/admin/shop")
@Slf4j
@Api(tags = "店铺的接口")
public class ShopController {

    @Autowired
    ShopService shopService;

    @GetMapping("/status")
    @ApiOperation("获取营业状态")
    public Result<Integer> getShopStatus(){
        Integer status = shopService.getShopStatus();
        return Result.success(status);
    }

    @PutMapping("/{status}")
    @ApiOperation("更改营业状态")
    public Result changShopWorkStatus(@PathVariable Integer status){
        log.info("切换状态值为：{}",status == 1?"营业中":"打烊");
        shopService.changeStatus(status);
        return Result.success();
    }
}
